<?php

namespace App\Model;

use App\Model\UserModel;
use Illuminate\Database\Eloquent\Model;

//后台模块表
class NoticeModel extends Model
{
	//定义一个表名
	protected $table = 'notice';
	//定义主键
	protected $primaryKey = 'id';
	protected $guarded = [];

	function getUsernameAttribute(){
		$user = UserModel::Dolist($this->uid);
		if($user['login_type'] == 1){
			return $user['phone'];
		}else{
			return $user['email'];
		}
	}

	static function doList(){
		$notice = [];
		$notices = NoticeModel::where('state',1)->where('type',1)->orderBy('sort','desc')->select('id','title')->get();

		return $notices;
	}
}